/**
*FileContentManager is a Java based file manager desktop application, 
*it can show, edit and manipulate the content of the files archived inside a zip.
*
*Copyright (C) 2007 
*
*Created by Camila Sanchez [http://mimix.wordpress.com/], Rafael Naufal [http://rnaufal.livejournal.com] and Rodrigo [rdomartins@gmail.com]
*
*FileContentManager is free software; you can redistribute it and/or
*modify it under the terms of the GNU Lesser General Public
*License as published by the Free Software Foundation; either
*version 2.1 of the License, or (at your option) any later version.
*
*This library is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*Lesser General Public License for more details.
*
*You should have received a copy of the GNU Lesser General Public
*License along with FileContentManager; if not, write to the Free Software
*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

package br.com.jteam.jfcm.gui.adapter;

import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;

/**
 * <p>
 * Respons&aacute;vel por criar o conte&uacute;do do tipo IMAGEM para visualiza&ccedil;&atilde;o.
 * 
 * @author Rafael Naufal <rafael.naufal@gmail.com>
 * @since 1.0
 * @version $Id$
 */
public class ImageFileContent implements FileContent<Image>
{
	/**
	 * <p>
	 * Contrutor package-private. Somente classes deste pacote t&ecirc;m acesso a este
	 * construtor.
	 * 
	 */
	ImageFileContent()
	{
		super();
	}

	/**
	 * <p>
	 * Cria&ccedil;&atilde;o de conte&uacute;do do tipo IMAGEM para
	 * visualiza&ccedil;&atilde;o.
	 * 
	 * @param is -
	 *            o stream de dados a ser lido para renderizar um
	 *            conte&uacute;do.
	 * @return - conte&uacute;do do arquivo, que &eacute; uma imagem.
	 * @throws ShowFileContentAdapterException -
	 *             Caso ocorra algum erro de entrada / sa&iacute;da na abertura
	 *             e leitura do arquivo.
	 */
	public Image generateFileContent(InputStream is) throws ShowFileContentAdapterException
	{
		if (is == null)
		{
			throw new IllegalArgumentException("ZipInputStream cannot be null");
		}
		try
		{
			return ImageIO.read(is);
		} catch (IOException e)
		{
			throw new ShowFileContentAdapterException(e);
		}
	}
}
